package com.zjgeport.zjgdanger.OnPortDynamics;

import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;

import com.zjgeport.zjgdanger.CommonActivity;
import com.zjgeport.zjgdanger.Exception.ExceptionMainActivity;
import com.zjgeport.zjgdanger.MainActivity;
import com.zjgeport.zjgdanger.R;
import com.zjgeport.zjgdanger.adapter.AppGridAdapter;

import java.util.ArrayList;
import java.util.HashMap;

public class OnPortMainActivity extends CommonActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_on_port_main);
        initCommonListener();
        initView();
    }

    private void initView() {
        findTextViewById(R.id.title).setText("在港动态");
        int widthScreen  = getWindow().getWindowManager().getDefaultDisplay().getWidth();
        String names01[] = { "视频监控查看", "储罐动态数据","作业申报监管"};
        int draws01[] = { R.drawable.btn_app_item1, R.drawable.btn_app_item2,R.drawable.btn_app_item3};
        GridView gv_one = (GridView)findViewById(R.id.GridView_app);
        gv_one.setSelector(new ColorDrawable(Color.TRANSPARENT));
        ArrayList<HashMap<String, Object>> meumList = new ArrayList<HashMap<String, Object>>();
        for (int i = 0; i < names01.length; i++)
        {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("ItemImage", draws01[i]); // 为加载数据设置图标
            map.put("ItemText", names01[i]); // 设置其名称
            meumList.add(map);
        }
        // 为适配器中数据设置布局样式
        AppGridAdapter saItem = new AppGridAdapter(OnPortMainActivity.this, meumList,widthScreen - 3*14,0,0);
        gv_one.setAdapter(saItem); // 为应用网格视图增加数据来源
        gv_one.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                switch (i){
                    case 0:
                        Intent intent1 = new Intent(OnPortMainActivity.this, VideoListActivity.class);
                        startActivity(intent1);
                        break;
                    case 1:
                        Intent intent2 = new Intent(OnPortMainActivity.this, CompanyListActivity.class);
                        startActivity(intent2);
                        break;
                    case 2:
                        Intent intent3 = new Intent(OnPortMainActivity.this, DeclareListActivity.class);
                        startActivity(intent3);
                        break;
                }
            }
        });

    }
}
